home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / SLShAttr.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  12.9 KB  |  640 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                SLInk.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef PRSHATTR_H
  13. #include "PRShAttr.h"
  14. #endif
  15.  
  16. #ifndef FWODEXCE_H
  17. #include "FWODExce.h"
  18. #endif
  19.  
  20. #ifndef SLSHATTR_H
  21. #include "SLShAttr.h"
  22. #endif
  23.  
  24. #ifndef FWSTRMRW_H
  25. #include "FWStrmRW.h"
  26. #endif
  27.  
  28. #ifndef FWAROPER_H
  29. #include "FWArOper.h"
  30. #endif
  31.  
  32. //========================================================================================
  33. // Pattern
  34. //========================================================================================
  35.  
  36. #ifdef FW_BUILD_MAC
  37. #pragma segment FWGraphics_Pattern
  38. #endif
  39.  
  40. // Creation
  41.  
  42. FW_HPattern            SL_API    FW_PrivPattern_CreateBlack(FW_PlatformError* error)
  43. {
  44.     FW_ERR_TRY
  45.     {
  46.         return FW_NEW(FW_CPrivBWPatternRep, ());
  47.     }
  48.     FW_ERR_CATCH
  49.     return 0;    
  50. }
  51.  
  52. FW_HPattern            SL_API    FW_PrivPattern_CreateBW(const FW_BitPattern& bits, FW_PlatformError* error)
  53. {
  54.     FW_ERR_TRY
  55.     {
  56.         return FW_NEW(FW_CPrivBWPatternRep, (bits));
  57.     }
  58.     FW_ERR_CATCH
  59.     return 0;    
  60. }
  61.  
  62. FW_HPattern            SL_API    FW_PrivPattern_CreateColor(const FW_PixelPattern& pixels, short nbColors, const FW_SColor* colorTable, FW_PlatformError* error)
  63. {
  64.     FW_ERR_TRY
  65.     {
  66.         return FW_NEW(FW_CPrivColorPatternRep, (pixels, nbColors, colorTable));
  67.     }
  68.     FW_ERR_CATCH
  69.     return 0;    
  70. }
  71.  
  72. FW_HPattern            SL_API    FW_PrivPattern_CreateFromPlatformColorPattern(FW_PlatformColorPattern pattern, FW_PlatformError* error)
  73. {
  74.     FW_ERR_TRY
  75.     {
  76.         return FW_NEW(FW_CPrivColorPatternRep, (pattern));
  77.     }
  78.     FW_ERR_CATCH
  79.     return 0;    
  80. }
  81.  
  82. FW_HPattern            SL_API    FW_PrivPattern_Copy(FW_HPattern pattern, FW_PlatformError* error)
  83. {
  84.     FW_ERR_TRY
  85.     {
  86.         return pattern->Copy();
  87.     }
  88.     FW_ERR_CATCH
  89.     return 0;    
  90. }
  91.  
  92. // Reference counting
  93.  
  94. void                SL_API    FW_PrivPattern_Acquire(FW_HPattern pattern)
  95. {
  96.     // No try block necessary - Do not throw
  97.     pattern->Acquire();
  98. }
  99.  
  100. long                SL_API    FW_PrivPattern_GetRefCount(FW_HPattern pattern)
  101. {
  102.     // No try block necessary - Do not throw
  103.     return pattern->GetRefCount();
  104. }
  105.  
  106. void                SL_API    FW_PrivPattern_Release(FW_HPattern pattern)
  107. {
  108.     // No try block necessary - Do not throw
  109.     pattern->Release();
  110. }
  111.  
  112. // Comparison
  113.  
  114. FW_Boolean            SL_API    FW_PrivPattern_IsEqual(FW_HPattern pattern1, FW_HPattern pattern2)
  115. {
  116.     // No try block necessary - Do not throw
  117.     return pattern1->IsEqual(pattern2);
  118. }
  119.  
  120. // Operations
  121.  
  122. FW_PlatformError    SL_API    FW_PrivPattern_Invert(FW_HPattern pattern)
  123. {
  124.     // No try block necessary - Do not throw
  125.     pattern->Invert();
  126.     return FW_xNoError;
  127. }
  128.  
  129. FW_PlatformError    SL_API    FW_PrivPattern_FlipHorizontally(FW_HPattern pattern)
  130. {
  131.     // No try block necessary - Do not throw
  132.     pattern->FlipHorizontally();
  133.     return FW_xNoError;
  134. }
  135.  
  136. FW_PlatformError    SL_API    FW_PrivPattern_FlipVertically(FW_HPattern pattern)
  137. {
  138.     // No try block necessary - Do not throw
  139.     pattern->FlipVertically();
  140.     return FW_xNoError;
  141. }
  142.  
  143. FW_PlatformError    SL_API    FW_PrivPattern_ShiftUp(FW_HPattern pattern)
  144. {
  145.     // No try block necessary - Do not throw
  146.     pattern->ShiftUp();
  147.     return FW_xNoError;
  148. }
  149.  
  150. FW_PlatformError    SL_API    FW_PrivPattern_ShiftDown(FW_HPattern pattern)
  151. {
  152.     // No try block necessary - Do not throw
  153.     pattern->ShiftDown();
  154.     return FW_xNoError;
  155. }
  156.  
  157. FW_PlatformError    SL_API    FW_PrivPattern_ShiftLeft(FW_HPattern pattern)
  158. {
  159.     // No try block necessary - Do not throw
  160.     pattern->ShiftLeft();
  161.     return FW_xNoError;
  162. }
  163.  
  164. FW_PlatformError    SL_API    FW_PrivPattern_ShiftRight(FW_HPattern pattern)
  165. {
  166.     // No try block necessary - Do not throw
  167.     pattern->ShiftRight();
  168.     return FW_xNoError;
  169. }
  170.  
  171. // Streaming
  172.  
  173. FW_HPattern            SL_API    FW_PrivPattern_Read(FW_HReadableStream hStream, FW_PlatformError* error)
  174. {
  175.     FW_CPrivPatternRep* pattern;
  176.     FW_ERR_TRY
  177.     {
  178.         FW_CReadableStream stream(hStream);
  179.         FW_READ_DYNAMIC_OBJECT(stream, &pattern, FW_CPrivPatternRep);
  180.     }
  181.     FW_ERR_CATCH
  182.     return pattern;
  183. }
  184.  
  185. void                SL_API    FW_PrivPattern_Write(FW_HPattern pattern, FW_HWritableStream hStream, FW_PlatformError* error)
  186. {
  187.     FW_ERR_TRY
  188.     {
  189.         FW_CWritableStream stream(hStream);
  190.         FW_WRITE_DYNAMIC_OBJECT(stream, pattern, FW_CPrivPatternRep);
  191.     }
  192.     FW_ERR_CATCH
  193. }
  194.  
  195. //========================================================================================
  196. // Ink
  197. //========================================================================================
  198.  
  199. #ifdef FW_BUILD_MAC
  200. #pragma segment FWGraphics_Ink
  201. #endif
  202.  
  203. // Creation
  204.  
  205. FW_HInk                SL_API    FW_PrivInk_Create(FW_SColor fore, FW_SColor back, FW_TransferModes mode, FW_PlatformError* error)
  206. {
  207.     FW_ERR_TRY
  208.     {
  209.         return new FW_CPrivInkRep(fore, back, mode);
  210.     }
  211.     FW_ERR_CATCH
  212.     return 0;
  213. }
  214.  
  215. FW_HInk                SL_API    FW_PrivInk_CreateStandard(FW_EStandardInks std, FW_PlatformError* error)
  216. {
  217.     FW_ERR_TRY
  218.     {
  219.         return new FW_CPrivInkRep(std);
  220.     }
  221.     FW_ERR_CATCH
  222.     return 0;
  223. }
  224.  
  225. FW_HInk                SL_API    FW_PrivInk_Copy(FW_HInk ink, FW_PlatformError* error)
  226. {
  227.     FW_ERR_TRY
  228.     {
  229.         return new FW_CPrivInkRep(*ink);
  230.     }
  231.     FW_ERR_CATCH
  232.     return 0;
  233. }
  234.  
  235. // Reference counting
  236.  
  237. void                SL_API    FW_PrivInk_Acquire(FW_HInk ink)
  238. {
  239.     // No try block necessary - Do not throw
  240.     ink->Acquire();
  241. }
  242.  
  243. long                SL_API    FW_PrivInk_GetRefCount(FW_HInk ink)
  244. {
  245.     // No try block necessary - Do not throw
  246.     return ink->GetRefCount();
  247. }
  248.  
  249. void                SL_API    FW_PrivInk_Release(FW_HInk ink)
  250. {
  251.     // No try block necessary - Do not throw
  252.     ink->Release();
  253. }
  254.  
  255. // Attributes
  256.  
  257. FW_SColor            SL_API    FW_PrivInk_GetForeColor(FW_HInk ink)
  258. {
  259.     // No try block necessary - Do not throw
  260.     return ink->GetForeColor();
  261. }
  262.  
  263. FW_SColor            SL_API    FW_PrivInk_GetBackColor(FW_HInk ink)
  264. {
  265.     // No try block necessary - Do not throw
  266.     return ink->GetBackColor();
  267. }
  268.  
  269. FW_TransferModes    SL_API    FW_PrivInk_GetTransferMode(FW_HInk ink)
  270. {
  271.     // No try block necessary - Do not throw
  272.     return ink->GetTransferMode();
  273. }
  274.  
  275. // Comparison
  276.  
  277. FW_Boolean            SL_API    FW_PrivInk_IsEqual(FW_HInk ink, FW_HInk ink2)
  278. {
  279.     // No try block necessary - Do not throw
  280.     return ink->IsEqual(ink2);
  281. }
  282.  
  283. // Operations
  284.  
  285. void                SL_API    FW_PrivInk_SetForeColor(FW_HInk ink, FW_SColor color)
  286. {
  287.     // No try block necessary - Do not throw
  288.     ink->SetForeColor(color);
  289. }
  290.  
  291. void                SL_API    FW_PrivInk_SetBackColor(FW_HInk ink, FW_SColor color)
  292. {
  293.     // No try block necessary - Do not throw
  294.     ink->SetBackColor(color);
  295. }
  296.  
  297. void                SL_API    FW_PrivInk_SetTransferMode(FW_HInk ink, FW_TransferModes mode)
  298. {
  299.     // No try block necessary - Do not throw
  300.     ink->SetTransferMode(mode);
  301. }
  302.  
  303. // Streaming
  304.  
  305. FW_HInk                SL_API    FW_PrivInk_Read(FW_HReadableStream hStream, FW_PlatformError* error)
  306. {
  307.     FW_ERR_TRY
  308.     {
  309.         FW_CReadableStream stream(hStream);
  310.         return new FW_CPrivInkRep(stream);
  311.     }
  312.     FW_ERR_CATCH
  313.     return 0;
  314. }
  315.  
  316. void                SL_API    FW_PrivInk_Write(FW_HInk ink, FW_HWritableStream hStream, FW_PlatformError* error)
  317. {
  318.     FW_ERR_TRY
  319.     {
  320.         FW_CWritableStream stream(hStream);
  321.         ink->Write(stream);
  322.     }
  323.     FW_ERR_CATCH
  324. }
  325.  
  326. //========================================================================================
  327. // Style
  328. //========================================================================================
  329.  
  330. #ifdef FW_BUILD_MAC
  331. #pragma segment FWGraphics_Style
  332. #endif
  333.  
  334. // Creation
  335.  
  336. FW_HStyle            SL_API    FW_PrivStyle_CreateDash(FW_Fixed penSize, FW_EStyleDash dash, FW_PlatformError* error)
  337. {
  338.     FW_ERR_TRY
  339.     {
  340.         return FW_NEW(FW_CPrivStyleRep, (penSize, dash));
  341.     }
  342.     FW_ERR_CATCH
  343.     return 0;
  344. }
  345.  
  346. FW_HStyle            SL_API    FW_PrivStyle_CreatePattern(FW_Fixed penSize, FW_HPattern pattern, FW_PlatformError* error)
  347. {
  348.     FW_ERR_TRY
  349.     {
  350.         return FW_NEW(FW_CPrivStyleRep, (penSize, pattern));
  351.     }
  352.     FW_ERR_CATCH
  353.     return 0;
  354. }
  355.  
  356. FW_HStyle            SL_API    FW_PrivStyle_CreateStandard(FW_EStandardStyles std, FW_PlatformError* error)
  357. {
  358.     FW_ERR_TRY
  359.     {
  360.         return FW_NEW(FW_CPrivStyleRep, (std));
  361.     }
  362.     FW_ERR_CATCH
  363.     return 0;
  364. }
  365.  
  366. FW_HStyle            SL_API    FW_PrivStyle_Copy(FW_HStyle style, FW_PlatformError* error)
  367. {
  368.     FW_ERR_TRY
  369.     {
  370.         return FW_NEW(FW_CPrivStyleRep, (*style));
  371.     }
  372.     FW_ERR_CATCH
  373.     return 0;
  374. }
  375.  
  376. // Reference counting
  377.  
  378. void                SL_API    FW_PrivStyle_Acquire(FW_HStyle style)
  379. {
  380.     // No try block necessary - Do not throw
  381.     style->Acquire();
  382. }
  383.  
  384. long                SL_API    FW_PrivStyle_GetRefCount(FW_HStyle style)
  385. {
  386.     // No try block necessary - Do not throw
  387.     return style->GetRefCount();
  388. }
  389.  
  390. void                SL_API    FW_PrivStyle_Release(FW_HStyle style)
  391. {
  392.     // No try block necessary - Do not throw
  393.     style->Release();
  394. }
  395.  
  396. // Attributes
  397.  
  398. FW_Fixed            SL_API    FW_PrivStyle_GetPenSize(FW_HStyle style)
  399. {
  400.     // No try block necessary - Do not throw
  401.     return style->GetPenSize();
  402. }
  403.  
  404. FW_HPattern            SL_API    FW_PrivStyle_GetPattern(FW_HStyle style)
  405. {
  406.     // No try block necessary - Do not throw
  407.     return style->GetPattern();
  408. }
  409.  
  410. FW_HPattern            SL_API    FW_PrivStyle_GetUnSharedPattern(FW_HStyle style)
  411. {
  412.     // No try block necessary - Do not throw
  413.     return style->GetUnSharedPattern();
  414. }
  415.  
  416. FW_EStyleDash        SL_API    FW_PrivStyle_GetDashStyle(FW_HStyle style)
  417. {
  418.     // No try block necessary - Do not throw
  419.     return style->GetDashStyle();
  420. }
  421.  
  422. // Comparison
  423.  
  424. FW_Boolean            SL_API    FW_PrivStyle_IsEqual(FW_HStyle style, FW_HStyle style2)
  425. {
  426.     // No try block necessary - Do not throw
  427.     return style->IsEqual(style2);
  428. }
  429.  
  430. // Operations
  431.  
  432. void                SL_API    FW_PrivStyle_SetPenSize(FW_HStyle style, FW_Fixed penSize)
  433. {
  434.     // No try block necessary - Do not throw
  435.     style->SetPenSize(penSize);
  436. }
  437.  
  438. FW_PlatformError    SL_API    FW_PrivStyle_SetPattern(FW_HStyle style, FW_HPattern pattern)
  439. {
  440.     // No try block necessary - Do not throw
  441.     style->SetPattern(pattern);
  442.     return FW_xNoError;
  443. }
  444.  
  445. void                SL_API    FW_PrivStyle_SetDashStyle(FW_HStyle style, FW_EStyleDash dash)
  446. {
  447.     // No try block necessary - Do not throw
  448.     style->SetDashStyle(dash);
  449. }
  450.  
  451. // Streaming
  452.  
  453. FW_HStyle SL_API FW_PrivStyle_Read(FW_HReadableStream hStream, FW_PlatformError* error)
  454. {
  455.     FW_ERR_TRY
  456.     {
  457.         FW_CReadableStream stream(hStream);
  458.         return FW_NEW(FW_CPrivStyleRep, (stream));
  459.     }
  460.     FW_ERR_CATCH
  461.     return 0;
  462. }
  463.  
  464. void SL_API    FW_PrivStyle_Write(FW_HStyle style, FW_HWritableStream hStream, FW_PlatformError* error)
  465. {
  466.     FW_ERR_TRY
  467.     {
  468.         FW_CWritableStream stream(hStream);
  469.         style->Write(stream);
  470.     }
  471.     FW_ERR_CATCH
  472. }
  473.  
  474. //========================================================================================
  475. // Font
  476. //========================================================================================
  477.  
  478. #ifdef FW_BUILD_MAC
  479. #pragma segment FWGraphics_Font
  480. #endif
  481.  
  482. // Creation
  483.  
  484. FW_HFont SL_API    FW_PrivFont_Create(FW_HString fontName, FW_FontStyle fontStyle, FW_Fixed fontSize, FW_PlatformError* error)
  485. {
  486.     FW_ERR_TRY
  487.     {
  488.         FW_CString str(fontName);
  489.         return FW_NEW(FW_CPrivFontRep, (str, fontStyle, fontSize));
  490.     }
  491.     FW_ERR_CATCH
  492.     return 0;
  493. }
  494.  
  495. FW_HFont SL_API    FW_PrivFont_CreateStandard(FW_EStandardFonts std, FW_PlatformError* error)
  496. {
  497.     FW_ERR_TRY
  498.     {
  499.         return FW_NEW(FW_CPrivFontRep, (std));
  500.     }
  501.     FW_ERR_CATCH
  502.     return 0;
  503. }
  504.  
  505. FW_HFont SL_API    FW_PrivFont_Copy(FW_HFont font, FW_PlatformError* error)
  506. {
  507.     FW_ERR_TRY
  508.     {
  509.         return FW_NEW(FW_CPrivFontRep, (*font));
  510.     }
  511.     FW_ERR_CATCH
  512.     return 0;
  513. }
  514.  
  515. // Reference counting
  516.  
  517. void SL_API    FW_PrivFont_Acquire(FW_HFont font)
  518. {
  519.     // No try block necessary - Do not throw
  520.     font->Acquire();
  521. }
  522.  
  523. long SL_API    FW_PrivFont_GetRefCount(FW_HFont font)
  524. {
  525.     // No try block necessary - Do not throw
  526.     return font->GetRefCount();
  527. }
  528.  
  529. void SL_API    FW_PrivFont_Release(FW_HFont font)
  530. {
  531.     // No try block necessary - Do not throw
  532.     font->Release();
  533. }
  534.  
  535. // Attributes
  536.  
  537. FW_Fixed SL_API    FW_PrivFont_GetSize(FW_HFont font)
  538. {
  539.     // No try block necessary - Do not throw
  540.     return font->GetFontSize();
  541. }
  542.  
  543. FW_FontStyle SL_API    FW_PrivFont_GetStyle(FW_HFont font)
  544. {
  545.     // No try block necessary - Do not throw
  546.     return font->GetFontStyle();
  547. }
  548.  
  549. void SL_API    FW_PrivFont_GetName(FW_HFont font, FW_HString* fontName, FW_PlatformError* error)
  550. {
  551.     FW_ERR_TRY
  552.     {
  553.         FW_CString str(*fontName);
  554.         font->GetFontName(str);
  555.     }
  556.     FW_ERR_CATCH
  557. }
  558.  
  559. // Comparison
  560.  
  561. FW_Boolean SL_API FW_PrivFont_IsEqual(FW_HFont font, FW_HFont font2)
  562. {
  563.     // No try block necessary - Do not throw
  564.     return font->IsEqual(font2);
  565. }
  566.  
  567. // Operations
  568.  
  569. void SL_API    FW_PrivFont_SetSize(FW_HFont font, FW_Fixed size)
  570. {
  571.     // No try block necessary - Do not throw
  572.     font->SetFontSize(size);
  573. }
  574.  
  575. void SL_API    FW_PrivFont_SetStyle(FW_HFont font, FW_FontStyle style)
  576. {
  577.     // No try block necessary - Do not throw
  578.     font->SetFontStyle(style);
  579. }
  580.  
  581.  
  582. void SL_API    FW_PrivFont_SetName(FW_HFont font, FW_HString fontName, FW_PlatformError* error)
  583. {
  584.     FW_ERR_TRY
  585.     {
  586.         FW_CString str(fontName);
  587.         font->SetFontName(str);
  588.     }
  589.     FW_ERR_CATCH
  590. }
  591.  
  592. // Streaming
  593.  
  594. FW_HFont SL_API    FW_PrivFont_Read(FW_HReadableStream hStream, FW_PlatformError* error)
  595. {
  596.     FW_ERR_TRY
  597.     {
  598.         FW_CReadableStream stream(hStream);
  599.         return FW_NEW(FW_CPrivFontRep, (stream));
  600.     }
  601.     FW_ERR_CATCH
  602.     return 0;
  603. }
  604.  
  605. void SL_API    FW_PrivFont_Write(FW_HFont font, FW_HWritableStream hStream, FW_PlatformError* error)
  606. {
  607.     FW_ERR_TRY
  608.     {
  609.         FW_CWritableStream stream(hStream);
  610.         font->Write(stream);
  611.     }
  612.     FW_ERR_CATCH
  613. }
  614.  
  615. // Macintosh-only
  616.  
  617. #ifdef FW_BUILD_MAC
  618. short SL_API FW_PrivFont_MacGetFontID(FW_HFont font)
  619. {
  620.     // No try block necessary - Do not throw
  621.     return font->MacGetFontID();
  622. }
  623.  
  624. Style SL_API FW_PrivFont_MacGetFontStyle(FW_HFont font)
  625. {
  626.     // No try block necessary - Do not throw
  627.     return font->MacGetFontStyle();
  628. }
  629.  
  630. void SL_API FW_PrivFont_MacSetFontID(FW_HFont font, short macFontID, FW_PlatformError* error)
  631. {
  632.     FW_ERR_TRY
  633.     {
  634.         font->MacSetFontID(macFontID);
  635.     }
  636.     FW_ERR_CATCH
  637. }
  638.  
  639. #endif
  640.